package com.situ;

import java.awt.ScrollPaneAdjustable;
import java.io.FileNotFoundException;
import java.util.Scanner;

import org.junit.Test;
import org.junit.validator.PublicClassValidator;
import org.omg.CORBA.PUBLIC_MEMBER;

public class HelloWord {
	public static void main(String[] args) {
		System.out.println("Hello word!");
	}
@Test
public void aaa(){
	System.out.println("HelloWord.aaa()");
}
@Test
public void java(){
	System.out.println("HelloWord.java()");
	
}
	@Test//加减乘除
	public void test5(){
		int num1 = 3;
		int num2 =9 ;
		int result = num1 + num2;
		int result2 = num1 - num2;
		int result3 = num1 * num2;
		int result4 = num2 / num1;
		int result5 = num2 % num1;
		System.out.println(result);	
		System.out.println(result2);
		System.out.println(result3);
		System.out.println(result4);
		System.out.println(result5);
		System.out.println(9 % 2);
		
}
	@Test
	public void test6(){
		int num1 = 3;
		   int num2 = 5;
		   // &&短路
		   System.out.println(num1 < 0 && num1++ < num2);//false
		   System.out.println(num1);// 3
		   System.out.println(num2);// 5
		   // || 短路
		   System.out.println(num1 > 0 || num1++ < num2);
		   System.out.println(num1);// 3
		   System.out.println(num2);// 5	
	}
	@Test 
	public void test7(){
		int sum = 4;
		sum++;
		System.out.println(sum);//5
		System.out.println(sum++);//5//6
		System.out.println(++sum);//7
	}
	@Test
	public void test8(){
		int sum1 = 7;
		int sum2 = 9;
		int java = sum1 < sum2 ? sum1:sum2;
		System.out.println(java);
		System.out.println("我的年龄"+sum1);
	}
	@Test
	public void test(){
		int i2=8;
		int i5 = 9;
		System.out.println(i2>i5?i2:i5);
		
	}
	@Test//换位
	public void test9(){
		int i4 = 5;
		int i6 = 7;
		System.out.println("before" + i4);
		System.out.println("before" + i6);
		int temp = i4;
		i4 = i6;
		i6 = temp;
		System.out.println("hou" + i4);
		System.out.println("hou" + i6);
		
	}
	@Test
	public void test10(){
		int i = 1;
		int sum = 0;
		while(i<=100){
			System.out.println(i);
			sum = sum + i;
			i++;	
		}
		System.out.println("和为" + sum);
	}
	@Test//乘法表
	public void test11(){
		int a = 1;
		while (a <= 9) {
		int b = 1;
		while (b <= a) {
		System.out.print(b + "*" + a+ "=" + a * b + "\t");
		b++;
		}
		a++;
		System.out.println();
		}	
		
	}
	
	@Test//猜数1
	public void tset12(){
		int random = (int)(Math.random() * 1000 +1);
//		System.out.println(random);
		Scanner scanner = new Scanner (System.in);
		System.out.println("请猜");
		int x = scanner.nextInt();
		while (x != random) {
			if (x < random) {
				System.out.println("太小了");
			}
			else if (x > random){
				System.out.println("太大了");
			}
			System.out.println("再猜");
			x = scanner.nextInt();
		}
		System.out.println("恭喜你猜对了");
		System.out.println("结束");
	}
	@Test//猜数2
	public void test12(){
		int random = (int)(Math.random() * 1000 + 1);
		System.out.println(random);
		Scanner scanner = new Scanner(System.in);
		while(true){
			System.out.println("请猜");
			int x = scanner.nextInt();
			if (x < random) {
			System.out.println("太小了");	
			}else if (x > random){
				System.out.println("太大了");
			}else {
				System.out.println("恭喜你猜对了");
				break;
			}
		}
		System.out.println("结束");
	}
	@Test //计数
	public void test13(){
		int sum = 0;//计数
		for (int i = 1; i <= 100; i++) {
			if (i % 9 == 0) {
				System.out.println(i);
				sum++;
			}
		}
		System.out.println(sum);
	}
	@Test//输出*
	public void test14(){
		for (int i = 1; i <= 3; i++) {
			for (int j = 1; j <= 4; j++) {
				System.out.print("*");
			}
			System.out.println();
			
		}
	}
	@Test
	public void test15(){//输出*
		for (int i = 1; i <= 5; i++) {       //外层循环行数
			for (int j = 1;j <= i+3; j++) {    //个数数
				System.out.print("*");
			}
			System.out.println();
		}
		
	}
	@Test
	public void test16(){
		for(int i = 1; i <= 9; i++){
			for (int j = 1;j <= i; j++){
				System.out.print(j + "*" + i + "=" +(i*j) +"\t");
			}
			System.out.println();
		}
	}
		
	} 
		
